package com.huawei123.hasee.cniao5store.mvp.presenter.impl;

import com.huawei123.hasee.cniao5store.api.IGetDataDelegate;
import com.huawei123.hasee.cniao5store.base.BaseActivity;
import com.huawei123.hasee.cniao5store.base.mvp_base.MvpPresenterImpl;
import com.huawei123.hasee.cniao5store.bean.RecommendBean;
import com.huawei123.hasee.cniao5store.mvp.interactor.RecommendInteractor;
import com.huawei123.hasee.cniao5store.mvp.presenter.RecommendFragmentPresenter;
import com.huawei123.hasee.cniao5store.mvp.view.view.RecommendFragmentView;

import javax.inject.Inject;

/**
 * 项目名称：Cniao5Store
 * 类描述：推荐页实现类 开始加载
 * 创建人：Administrator
 * 创建时间：2017/11/12 0012 下午 3:12
 * 修改人：Administrator
 * 修改时间：2017/11/12 0012 下午 3:12
 * 修改备注：
 */

public class RecommendPresenterImpl extends MvpPresenterImpl<RecommendFragmentView> implements RecommendFragmentPresenter {
    @Inject
    RecommendInteractor recommendInteractor;
    @Inject
    public RecommendPresenterImpl() {

    }
    /**
     * 写入网络请求等数据来源处理
     */
    @Override
    public void getRecommendData(BaseActivity activity) {
        //网络请求获取数据
        recommendInteractor.loadRecommendData(activity, new IGetDataDelegate<RecommendBean>() {
            @Override
            public void getDataSuccess(RecommendBean recommendBean) {
                myPresenterView.requestDataSuccess(recommendBean);
            }

            @Override
            public void getDataError(String errmsg) {
                myPresenterView.requestDataError(errmsg);
            }
        });
    }

    @Override
    public void getRecommendDataMore(BaseActivity activity) {
        //网络请求获取数据
        recommendInteractor.loadRecommendData(activity, new IGetDataDelegate<RecommendBean>() {
            @Override
            public void getDataSuccess(RecommendBean recommendBean) {
                myPresenterView.requestMoreRecommend(recommendBean);
            }

            @Override
            public void getDataError(String errmsg) {
                myPresenterView.requestDataError(errmsg);
            }
        });
    }
}
